set more off
stset count, fail(terminate) id(groupid)
*Table 2, model 1*
stcox    repression polity gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , robust tvc(size  polity religious foreignpresence) 
*Table 2, model 2, interaction*
stcox     pol_repression repression polity gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , robust tvc(size repression polity religious foreignpresence) 
*Table 2, model 3, Weibull Model*
streg     repression polity pol_repression gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , dist(weibull) robust
*Table 3, Marginal effects for table 2*
*Model 1 table 2*
stcox      repression polity gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , robust tvc(size  polity religious foreignpresence) 
margins, atmeans at(  pop_ln=15.74) at(  pop_ln=19.68)
margins, atmeans at( size=1) at(size=3)
margins, atmeans at( nationalist=0) at(nationalist=1)
margins, atmeans at(goalbreadth=2) at(goalbreadth=5)
*Model 2 table 2*
stcox     pol_repression repression polity gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , robust tvc(size repression polity religious foreignpresence) 
margins, atmeans at(polity=10 repression=1.5 pol_repression=15) at(polity=10 repression=4.5 pol_repression=45)
margins, atmeans at(polity=-3 repression=1.5 pol_repression=-4.5) at(polity=-3 repression=4.5 pol_repression=-13.5)
margins, atmeans at(  pop_ln=15.74) at(  pop_ln=19.68)
margins, atmeans at( size=1) at(size=3)
margins, atmeans at( nationalist=0) at(nationalist=1)
margins, atmeans at(goalbreadth=2) at(goalbreadth=5)
*Model 3, table 2*
streg     repression polity pol_repression gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , dist(weibull) robust
margins, atmeans at(polity=10 repression=1.5 pol_repression=15) at(polity=10 repression=4.5 pol_repression=45)
margins, atmeans at(polity=-3 repression=1.5 pol_repression=-4.5) at(polity=-3 repression=4.5 pol_repression=-13.5)
margins, atmeans at(  pop_ln=15.74) at(  pop_ln=19.68)
margins, atmeans at( size=1) at(size=3)
margins, atmeans at( religious=0) at(religious=1)
margins, atmeans at(goalbreadth=2) at(goalbreadth=5)
*Table 4, outcome models*
*Table 4, model 1, Splinters*
stset count, fail( terminatetypenew=1) id(groupid)
stcrreg     repression polity pol_repression gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , compete(terminatetypenew== 2 3 4) tvc(size repression polity religious foreignpresence)robust
*Table 4, model 2, Government victory*
stset count, fail( terminatetypenew=2) id(groupid)
stcrreg     repression polity pol_repression gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , compete(terminatetypenew== 1 3 4) tvc(size repression polity religious foreignpresence)robust
*Table 4, model 3, Group victory*
stset count, fail( terminatetypenew=3) id(groupid)
stcrreg     repression polity pol_repression gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , compete(terminatetypenew== 1 2 4) tvc(size repression polity religious foreignpresence)robust
*Table 4, model 4, Settlement*
stset count, fail( terminatetypenew=4) id(groupid)
stcrreg     repression polity pol_repression gdpcappwt_ln pop_ln size leftist religious nationalist goalbreadth foreignpresence , compete(terminatetypenew== 1 2 3 )tvc(size repression polity religious foreignpresence) robust
stset count, fail(terminate) id(groupid)
